#include "UdpServer.hpp"
#include "User.hpp"
#include <memory>

int main(int argc, char *argv[])
{
    ENABLE_CONSOLE_LOG();

    std::shared_ptr<UserManager> um_sptr = std::make_shared<UserManager>();
    std::unique_ptr<UdpServer> ser_utpr = std::make_unique<UdpServer>(std::stoi(argv[1]));

    ser_utpr->InitServer();
    ser_utpr->RegisterService([&um_sptr](const InetAddr &id)
                              { um_sptr->AddUser(id); },
                              [&um_sptr](int sokfd, std::string &message)
                              { um_sptr->Route(sokfd, message); },
                              [&um_sptr](const InetAddr &id)
                              { um_sptr->DelUser(id); });
    ser_utpr->Start();

    return 0;
}